//
//  RMMHomeShareView.m
//  Romomo
//
//  Created by puman on 16/10/11.
//  Copyright © 2016年 mazegong. All rights reserved.
//

#import "RMMHomeShareView.h"

@implementation RMMHomeShareView
- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        _backView = [[UIView alloc] initWithFrame:self.bounds];
        _backView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.4];
        _backView.alpha=0.0;
        [self addSubview:_backView];
        
        UIButton *buttons = [UIButton buttonWithType:(UIButtonTypeCustom)];
        buttons.frame = CGRectMake(0, 0, kScreenWideth, _backView.height - 230);
        BUTTON_S(buttons, cancelButClick);
        [_backView addSubview:buttons];

        _view = [[UIView alloc] initWithFrame:CGRectMake(0, kScreenHeight, self.width, 230)];
        _view.backgroundColor = [UIColor whiteColor];
        [self addSubview:_view];

        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(15, 0, kHalf, 44)];
        label.text = @"分享至";
        label.textColor = COLORFROMCODE(0x4A4A4A, 1);
        label.font = kFont(13);
        [_view addSubview:label];
        
        _copysBut = [UIButton buttonWithType:(UIButtonTypeCustom)];
        _copysBut.frame = CGRectMake(_view.width - 75, 0, 60, 44);
        [_copysBut setTitleColor:kBasicColor forState:(UIControlStateNormal)];
        [_copysBut setTitle:@"复制链接" forState:(UIControlStateNormal)];
        _copysBut.titleLabel.font = kFont(13);
       // [_view addSubview:_copysBut];
        
        UILabel *lineLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, label.bottom, _view.width, 0.5)];
        lineLabel.backgroundColor = RGBA(221, 221, 221, 1);
        [_view addSubview:lineLabel];
        
        CGFloat width = (kScreenWideth - 280) / 4;
        NSArray *array = @[@"微信23@3x",@"朋友圈@3x",@"QQ23@3x",@"微博44@3x",@"QQ空间@3x"];
        NSArray *titleArray = @[@"微信好友",@"朋友圈",@"QQ好友",@"微博",@"空间"];
        for (int i = 0; i < 5; i++) {
            UIButton *shareBut = [UIButton buttonWithType:(UIButtonTypeCustom)];
            shareBut.frame = CGRectMake(15 + (50 + width) * i,lineLabel.bottom + 28, kHalf, 80);
            [shareBut setImage:[UIImage imageNamed:array[i]] forState:(UIControlStateNormal)];
            [shareBut setTitle:titleArray[i] forState:(UIControlStateNormal)];
            [shareBut setTitleColor:COLORFROMCODE(0x9B9B9B, 1) forState:(UIControlStateNormal)];
            shareBut.titleLabel.font = kFont(12);
            shareBut.tag = 50 + i;
            [_view addSubview:shareBut];
            if (i > 1) {
                shareBut.hidden = YES;
            }
            [shareBut setImageEdgeInsets:UIEdgeInsetsMake(- 15,0,0,0)];
            shareBut.titleEdgeInsets = UIEdgeInsetsMake(60, - shareBut.titleLabel.bounds.size.width-50, 0, 0);
            
        }
        
        UILabel *lineLabels = [[UILabel alloc] initWithFrame:CGRectMake(0, _view.height - 49, _view.width, 0.5)];
        lineLabels.backgroundColor = RGBA(221, 221, 221, 1);
        [_view addSubview:lineLabels];
        
        UIButton *cancelBut = [UIButton buttonWithType:(UIButtonTypeCustom)];
        cancelBut.frame = CGRectMake(0,lineLabels.bottom , _view.width, 48.5);
        [cancelBut setTitle:@"取消" forState:(UIControlStateNormal)];
        [cancelBut setTitleColor:COLORFROMCODE(0x4A4A4A, 1) forState:(UIControlStateNormal)];
        cancelBut.titleLabel.font = kFont(18);
        BUTTON_S(cancelBut, cancelButClick);
        [_view addSubview:cancelBut];
        
        UIView *gView = [[UIView alloc] initWithFrame:CGRectMake(0, lineLabel.bottom +126, _view.width,_view.height - 49 - lineLabel.bottom - 126)];
        gView.backgroundColor = RGBA(243, 242, 243, 1);
        [_view addSubview:gView];

    }
    return self;
}
- (void)cancelButClick{
    [UIView animateWithDuration:kInterval animations:^{
        _view.frame = CGRectMake(0, kScreenHeight, kScreenWideth, 230);
        _backView.alpha = 0.0;
    } completion:^(BOOL finished) {
        self.hidden = YES;
    }];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
